/**
 * 
 */
package info.niwota.webagent;

import info.niwota.org.json.JSONObject;
import info.niwota.webagent.peer.ChannelManager;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @author qiangli
 * 
 */
@SuppressWarnings("serial")
public class ChannelServlet extends BaseServlet {
	private static final Logger log = Logger.getLogger(ChannelServlet.class
			.getName());

	private static final ChannelManager manager = ChannelManager.getInstance();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {

		log.info("url: " + req.getRequestURL() + " query: "
				+ req.getQueryString());

		JSONObject data = manager.createChannel(req);

		sendJSON(req, res, data);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		doGet(req, res);
	}
}
